/*
Copyright (C) 2010  Christoph Schnack, Berlin (Germany)

This file is part of Tribuit.

    Tribuit is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    Tribuit is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Tribuit.  If not, see <http://www.gnu.org/licenses/>.
*/
package PDPictureEditor;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Point;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;

import GuiTools.CustomTextArea;
import GuiTools.Header;
import Settings.Settings;

/**
 * @author Christoph Schnack
 *
 */
class InfoText{
	static String infoText = "";
	public static String getInfoText(Settings set,JFrame pedFrame,String iText,String headerText){
		infoText=iText;
		final JDialog dialog = new JDialog(pedFrame,true);
		dialog.setTitle("Infotext");
		final CustomTextArea textArea = new CustomTextArea(iText==null?"":iText,true,true);
		JScrollPane jsp = new JScrollPane(textArea);
		jsp.setPreferredSize(new Dimension(200,200));
		JButton okBtn = new JButton("ok");
		okBtn.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e){
				infoText = textArea.getText();
				dialog.dispose();
			}
		});
		JButton cancelBtn = new JButton(set.getLanguage().getCancel());
		cancelBtn.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e){
				dialog.dispose();
			}
		});
		JPanel buttonPanel = new JPanel();
		buttonPanel.add(okBtn);
		buttonPanel.add(cancelBtn);
		dialog.getContentPane().add(BorderLayout.NORTH,new Header(headerText));
		dialog.getContentPane().add(BorderLayout.CENTER,jsp);
		dialog.getContentPane().add(BorderLayout.SOUTH,buttonPanel);
		dialog.pack();
		Point pos = pedFrame.getLocationOnScreen();
		dialog.setLocation(pos.x+50,pos.y+50);
		dialog.setVisible(true);
		return infoText;
	}
}
